package com.itboye.ihomebank.key;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.itboye.ihomebank.KeyFragment;
import com.itboye.ihomebank.R;
import com.itboye.ihomebank.base.BaseOtherActivity;
import com.itboye.ihomebank.bean.KeyBean;
import com.itboye.ihomebank.ttKey.Operation;

/**
 * 管理员用户（锁）
 * 
 */
public class ActivityGuanLiKey extends BaseOtherActivity  {
	ImageView key_finish;// 返回
	TextView key_title;// 标题
	ImageView key_shezhi;// 设置
	ImageButton icon;// 开锁
	// 发送钥匙，发送密码，用户管理，开锁记录
	LinearLayout key_send_yaoshi, key_send_pass, key_guanli, key_jilu;
	private String keyName;
	private String lockid;
	private String type;
	private String keyid;
	private String lockAlias;
	KeyBean keyBean;
	LinearLayout bottom;
	String lockMac;

	private String deviceName;

	public static boolean addLock = false;
	
	public static String device;

	@Override
	public void onClick(View v) {
		Intent intent = null;
		switch (v.getId()) {
		case R.id.key_finish:
			finish();
			break;
		case R.id.key_shezhi:// 设置
			intent = new Intent(this, ActivityKeySheZhiTwo.class);
			intent.putExtra("lockid", lockid);
			intent.putExtra("keyid", keyid);
			intent.putExtra("lockAlias", lockAlias);
			startActivity(intent);

			break;
		case R.id.key_send_yaoshi:// 发送钥匙
			intent = new Intent(this, ActivitySendKey.class);
			intent.putExtra("lockid", lockid);
			startActivity(intent);
			break;
		case R.id.key_send_pass:// 发送密码
			intent = new Intent(this, ActivityFaSongPass.class);
			intent.putExtra("lockid", lockid);
			startActivity(intent);
			break;
		case R.id.key_guanli:// 用户管理
			intent = new Intent(this, ActivityYongHuGuanLi.class);
			intent.putExtra("lockid", lockid);
			startActivity(intent);
			break;
		case R.id.key_jilu:// 开锁记录
			intent = new Intent(this, ActivityKaiSuoJiLuOne.class);
			// intent.putExtra("touid", touid);
			intent.putExtra("keyid", keyid);
			intent.putExtra("lockid", lockid);
			startActivity(intent);
			break;
		case R.id.icon://开锁
//			DoorKey doorKey = dbos.getDoorKeyFromLockName(keyBean
//					.getLockAlilas());
//			String mac = doorKey.getLockMac().toString();
//			device = mBluetoothAdapter.getRemoteDevice(lockMac).toString();
//			KeyFragment.mScienerAPI.connect(device);
			addLock = true;
			
			KeyFragment.bleSession.setOperation(Operation.UNLOCK);
			KeyFragment.bleSession.setLockmac(lockMac);
			
		//	KeyFragment.mTTLockAPI.connect(lockMac);
			break;
		default:
			break;
		}

	}

	@Override
	protected int layout_id() {
		// TODO Auto-generated method stub
		return R.layout.activity_guanli_key;
	}

	@Override
	protected void onInitController() {

	}

	@Override
	protected void onInit() {
		keyName = getIntent().getStringExtra("keyName");
		lockid = getIntent().getStringExtra("lockid");
		keyid = getIntent().getStringExtra("keyid");
		type = getIntent().getStringExtra("type");
		lockAlias= getIntent().getStringExtra("lockAlias");
		deviceName = getIntent().getStringExtra("lockName");
		
		lockMac = getIntent().getStringExtra("lockMac");
		keyBean = (KeyBean) getIntent().getSerializableExtra("model");
			key_title.setText(lockAlias);

	}

	@Override
	protected void onReadIntent(Bundle bundle) {

	}


}
